import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AdminModule } from './admin/admin.module';
import { ApiModule } from './api/api.module';
import { SharedModule } from './shared/shared.module';
import { WinstonModule } from 'nest-winston';
import * as winston from 'winston';
const { combine, timestamp, printf } = winston.format;
@Module({
  imports: [
    WinstonModule.forRoot({
      transports: [
        new winston.transports.Console({
          level: process.env.NODE_ENV === 'production' ? 'info' : 'debug',
          format: combine(
            timestamp({format: 'YYYY-MM-DD HH:mm:ss'}),
            winston.format.colorize(),
            printf(({ level, message, timestamp,context }) => {
              return `[Nest] ${process.pid} -  ${timestamp} ${level} [${context}] ${message}`;
            }),
          )
        }),
        new winston.transports.File({
          filename: 'logs/error.log',
          level: 'error',
        }),
      ]
    }),
    AdminModule, ApiModule, SharedModule],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
